import pygame as pg

# 初始化pygame
pg.init()

# 创建一个窗口(表面)
window = pg.display.set_mode((800, 600))

# 设置窗口标题
pg.display.set_caption("Hello Pygame!")

# 设置窗口背景颜色
window.fill((227, 227, 227))

# 绘制线
pg.draw.line(window, 'red', (50, 50), (150, 150), 5)
pg.draw.aaline(window, 'red', (50, 100), (150, 200))

# 绘制连续多条线(首尾相连也可绘制多边形)
points = [(50,50), (50,180), (200,100)]
points1 = [(50,100), (50,230), (200,150)]
pg.draw.lines(window, 'orange', True, points, 5)
pg.draw.aalines(window, 'orange', True, points1)

# 绘制多边形
points2 = [(50,150), (50,280), (200,200)]
pg.draw.polygon(window, 'yellow', points2, 5)

# 绘制矩形
pg.draw.rect(window, 'green', (300, 300, 150, 35))  # 对于绘制形状的函数（rect, polygon, circle等）线宽默认为0，表示填充整个形状
pg.draw.rect(window, 'cyan', (300, 350, 150, 35), 2)  # 绘制指定宽度的边框，内部不填充
pg.draw.rect(window, 'blue', (300, 400, 150, 35), 2, 15)  # 圆角半径
pg.draw.rect(window, 'purple', (300, 450, 150, 35), 2, -1, 0, 15, 15, 0)  # 为每个角指定不同的圆角半径(会覆盖前面的设置)

# 绘制圆
# 正圆
pg.draw.circle(window, 'pink', (400, 100), 50)  # 填充圆
pg.draw.circle(window, 'pink', (500, 100), 50, 1)  # 绘制指定宽度的边框，只有边框
pg.draw.circle(window, 'pink', (600, 100), 50, draw_top_left=True)  # 填充饼
pg.draw.circle(window, 'pink', (700, 100), 50, 1, draw_top_left=True)
# 椭圆
pg.draw.ellipse(window, 'orange', (400, 200, 80, 50))
pg.draw.ellipse(window, 'orange', (500, 200, 80, 50), 5)

# 绘制弧
pg.draw.arc(window, 'yellow', (600, 200, 150, 40), 0, 1.562)

# 更新窗口
pg.display.update()

# 暂停一会，让我看见窗口
pg.time.wait(5000)

# 清理，退出pygame
pg.quit()